package fragment.detialfragment;


import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.List;

import bean.BranchBean;
import qf.wlh.com.oneprisdent.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class BranchDetialFragment extends Fragment {


    private TextView tvTitle;
    private TextView tvContent;
    private ImageView ivImageView;
    private List<BranchBean.DataBean> list;
    private String transition ;
    private String transition2;

    public BranchDetialFragment() {
        // Required empty public constructor
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        Bundle bundle = getArguments();
        list = ((List<BranchBean.DataBean>) bundle.get("key"));
        transition = bundle.getString("name1");
        transition2 = bundle.getString("name2");
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        getActivity().setTitle("dajiahao");
        View view = inflater.inflate(R.layout.fragment_branch_detial,container,false);
        tvTitle = ((TextView) view.findViewById(R.id.branch_fragment_title_detial));
        tvContent = ((TextView) view.findViewById(R.id.branch_fragment_content_detial));
        ivImageView = ((ImageView) view.findViewById(R.id.branch_fragment_imageview_detial));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
            ivImageView.setTransitionName(transition);
            tvTitle.setTransitionName(transition2);
        }
        // 把每个图片视图设置不同的Transition名称, 防止在一个视图内有多个相同的名称, 在变换的时候造成混乱
        // Fragment支持多个View进行变换, 使用适配器时, 需要加以区分

        tvTitle.setText(list.get(0).getTitle());
        tvContent.setText(list.get(0).getDesc());
        Picasso.with(getContext()).load(list.get(0).getCover()).into(ivImageView);

        return view;
    }

}
